package com.application.fabric.fabriccontrol.operate.controlfabric;


import com.application.fabric.fabriccontrol.operate.entityfabric.BasicAsset;
import com.application.fabric.fabriccontrol.operate.serverfabric.MysqlFabricServer;
import com.application.fabric.fabriccontrol.operate.serverfabric.ServeAsset;
import com.application.fabric.users.entity.ExtractToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/myassets")
public class Myassets {

    @Autowired
    private ServeAsset serveAsset;
    @Resource
    public ExtractToken token;
    //    创建资产 id前端传递

    @Autowired
    private MysqlFabricServer mysqlFabricServer;
    @GetMapping("queryassetbyowner")
    public Map<String,Object> Queryassetbyowner(@RequestParam("userid") String assetid) throws Exception{
//        先做异常处理 就是判断资产在不在
//        在的化进行查询 不再的化返回资产查询为空
        Map<String,Object> map = new HashMap<>();
        List<BasicAsset> result = mysqlFabricServer.queryassetbyidservice(assetid);

        map.put("code",200);
        map.put("msg","查询成功");
        map.put("data",result);
        return map;
    }

}
